<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.jiadakeji.ppm.modules.sys.utils.*" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>房屋管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/business/room/">房屋列表</a></li>
		<li class="active"><a href="${ctx}/business/room/form?id=${room.id}">房屋<shiro:hasPermission name="business:room:edit">${not empty room.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="business:room:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="room" action="${ctx}/business/room/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">小区：</label>
			<div class="controls">
				<form:select path="communityId" class="input-xlarge ">
                    <form:option value="">请选择</form:option>
					<form:options items="${fns:getCommunityList()}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">楼栋：</label>
			<div class="controls">
				<input type="hidden" name="hidden_buildingId" value="${room.buildingId}"/>
				<form:select path="buildingId" class="input-xlarge ">
					<form:option value="">请选择</form:option>
                    <form:options items="${fns:getBuildingList()}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">房屋编号：</label>
			<div class="controls">
				<form:input path="code" htmlEscape="false" maxlength="32" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">楼层：</label>
			<div class="controls">
				<form:input path="storey" htmlEscape="false" maxlength="32" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">房屋名称：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="255" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">房屋平方价格类型：</label>
			<div class="controls">
				<form:select path="roomTypePriceId" class="input-medium">
					<form:options items="${fns:getRoomTypePriceList()}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">房产证：</label>
			<div class="controls">
				<form:input path="pot" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">建筑面积：</label>
			<div class="controls">
				<form:input path="buildAreaSize" htmlEscape="false" class="input-xlarge  number"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">使用面积：</label>
			<div class="controls">
				<form:input path="usingAreaSize" htmlEscape="false" class="input-xlarge  number"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">计费面积：</label>
			<div class="controls">
				<form:input path="feeAreaSize" htmlEscape="false" class="input-xlarge  number required"/>
                <span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">余额：</label>
			<div class="controls">
				<form:input path="balance" htmlEscape="false" class="input-xlarge  number" readonly="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否入住：</label>
			<div class="controls">
				<form:select path="useFlag" class="input-medium">
					<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">所有者id：</label>
			<div class="controls">
				<form:input path="houseHolderId"  htmlEscape="false" maxlength="32" class="input-xlarge " readonly="true"/>
				<button type="button" id="addUserButton" class="btn btn-primary">
					<i class="ace-icon fa fa-plus"></i>选择用户
				</button>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">使用者id：</label>
			<div class="controls">
				<form:input path="usingCustomerId" htmlEscape="false" maxlength="32" class="input-xlarge " readonly="true"/>
				<button type="button" id="addUserButton1" class="btn btn-primary">
					<i class="ace-icon fa fa-plus"></i>选择用户
				</button>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="business:room:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>

	<script src="${pageContext.request.contextPath}/static/common/list_relate.js"></script>
	<script src="${pageContext.request.contextPath}/static/common/pop_win.js"></script>
	<script>
        jQuery(function($) {
            // 选择联动，省市级联学校
            var parameter = {
                url : "/a/business/building/getBuildingList",
                key : "communityId",
                // dataList:"schoolList",
                value : "id",
                text : "name",
                selectedVal : ""
            };
            $("select[name='communityId']").ajaxRelate(
                $("select[name='buildingId']"), parameter);
            $("select[name='buildingId']").val($("input[name='hidden_buildingId']").val()).trigger("change");


        });
	</script>
	<script type="text/javascript">
        $("input[name=name]").focus();

        jQuery(function($) {

            $("#addUserButton").on("click",function(){
                popWin.showWin("950", "550", "所有者", "/a/business/customer/addUserList?replaceId=houseHolderId&replaceName=houseHolderName");
            });

            $("#addUserButton1").on("click",function(){
                popWin.showWin("950", "550", "使用者", "/a/business/customer/addUserList?replaceId=usingCustomerId&replaceName=usingCustomerName");
            });
        });


	</script>
</body>
</html>